package com.example.babyscope;

import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.MediaController;
import android.widget.SlidingDrawer;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
import android.widget.TextView;
import android.widget.VideoView;

public class MainActivity extends Activity {
	
	//Declaratie variablen
	
	long starttijd = 0;
	
	//Declaratie textviews
	
	static TextView tvRunTime;
	
	//Declaratie knoppen
    
    // Tab2 
    
    Button startStream; 
	Button stopStream;
	
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    
        //Initialisatie tab-menu
        
        TabHost th = (TabHost) findViewById(R.id.tabhost);
        th.setup();
        
        TabSpec specs = th.newTabSpec("tag1");
        
        specs.setContent(R.id.tab1);
        specs.setIndicator("Instructies");
        
        th.addTab(specs);
        specs = th.newTabSpec("tag2");
        specs.setContent(R.id.tab2);
        specs.setIndicator("Videostream");
        
        th.addTab(specs); 
        
        specs = th.newTabSpec("tag3");
        specs.setContent(R.id.tab3);
        specs.setIndicator("Instellingen");
        
        th.addTab(specs);
       
        //Initialisatie knoppen
       
        startStream = (Button) findViewById(R.id.bStartStream);
        stopStream = (Button) findViewById(R.id.bStopStream);
        
        //Initialisatie textview
        
        tvRunTime = (TextView) findViewById(R.id.tvRunTime);
        
        //video stream
        
        final VideoView videoView = (VideoView)findViewById(R.id.videoView1);
        MediaController mc = new MediaController(this);
        videoView.setMediaController(mc);
        
        //link waar de stream staat
        
        String str = "http://ie.microsoft.com/testdrive/graphics/videoformatsupport/big_buck_bunny_trailer_480p_baseline.mp4";
        Uri uri = Uri.parse(str);
        
        videoView.setVideoURI(uri);
        
        startStream.setOnClickListener(new View.OnClickListener() {
			
			public void onClick(View v) {
				// TODO Bij het indrukken van knop start-livestream
				
				videoView.requestFocus();
				videoView.start();
				videoView.resume();
				tvRunTime.setText("Livestream Online");
				
			}
		});
        
        stopStream.setOnClickListener(new View.OnClickListener() {
			
			public void onClick(View v) {
				// TODO Bij het indrukken van knop stop-livestream
				
				videoView.stopPlayback();
				videoView.clearFocus();
				tvRunTime.setText("Livestream gereed");
				
			}
		});
        
       
    }
}